package com.tbit.uqbike.webmanager.business.maintain_performance.constant;

import cn.hutool.core.map.MapUtil;
import lombok.Getter;

import java.util.Map;

/**
 * 换电绩效详情可选导出字段conditionBit值
 *
 * @author <a href="mailto:zheng.zebiao@tbit.com.cn">zb</a>
 * @since 2025/3/25
 */
@Getter
public class PerformanceExportField {
    public static class PowerChange {
        /**
         * 换电前后电量差值
         */
        public static final long socDiff = 1;
        /**
         * 换电首单时效
         */
        public static final long firstOrderTime = 1 << 1;
        /**
         * 换电24小时订单数
         */
        public static final long orderCountAfterChange = 1 << 2;
        /**
         * 站点名称
         */
        public static final long parkName = 1 << 3;
        /**
         * 绩效详情
         */
        public static final long performanceDetail = 1 << 4;

        private static final Map<String, Long> fieldMap = MapUtil.ofEntries(
                MapUtil.entry("socDiff", socDiff),
                MapUtil.entry("firstOrderTime", firstOrderTime),
                MapUtil.entry("orderCountAfterChange", orderCountAfterChange),
                MapUtil.entry("parkName", parkName),
                MapUtil.entry("performanceDetail", performanceDetail)
        );

        public static long getFieldBit(String fieldName) {
            return fieldMap.getOrDefault(fieldName, 0L);
        }
    }

    public static class Dispatch {
        /**
         * 调度前状态
         */
        public static final long beforeStatus = 1;
        /**
         * 调度后状态
         */
        public static final long afterStatus = 1 << 1;
        /**
         * 车辆标签
         */
        public static final long beforeTag = 1 << 2;
        /**
         * 调度首单时效(分钟)
         */
        public static final long firstOrderDuration = 1 << 3;
        /**
         * 调度24小时订单数
         */
        public static final long afterValidOrder = 1 << 4;
        /**
         * 绩效系数
         */
        public static final long performance = 1 << 5;
        /**
         * 绩效详情
         */
        public static final long performanceDetail = 1 << 6;

        private static final Map<String, Long> fieldMap = MapUtil.ofEntries(
                MapUtil.entry("beforeStatus", beforeStatus),
                MapUtil.entry("afterStatus", afterStatus),
                MapUtil.entry("beforeTag", beforeTag),
                MapUtil.entry("firstOrderDuration", firstOrderDuration),
                MapUtil.entry("afterValidOrder", afterValidOrder),
                MapUtil.entry("performance", performance),
                MapUtil.entry("performanceDetail", performanceDetail)
        );

        public static long getFieldBit(String fieldName) {
            return fieldMap.getOrDefault(fieldName, 0L);
        }
    }

    public static class Move {
        /**
         * 挪车类型
         */
        public static final long moveType = 1;
        /**
         * 挪车首单时效
         */
        public static final long firstOrderTime = 1 << 1;
        /**
         * 挪车24小时订单数
         */
        public static final long orderCountAfter24Hour = 1 << 2;
        /**
         * 挪车前状态
         */
        public static final long beforeStatus = 1 << 3;
        /**
         * 挪车后状态
         */
        public static final long afterStatus = 1 << 4;
        /**
         * 挪车距离(米)
         */
        public static final long moveTraceDistance = 1 << 5;
        /**
         * 绩效系数
         */
        public static final long performance = 1 << 6;
        /**
         * 绩效详情
         */
        public static final long performanceDetail = 1 << 7;

        private static final Map<String, Long> fieldMap = MapUtil.ofEntries(
                MapUtil.entry("moveType", moveType),
                MapUtil.entry("firstOrderTime", firstOrderTime),
                MapUtil.entry("orderCountAfter24Hour", orderCountAfter24Hour),
                MapUtil.entry("beforeStatus", beforeStatus),
                MapUtil.entry("afterStatus", afterStatus),
                MapUtil.entry("moveTraceDistance", moveTraceDistance),
                MapUtil.entry("performance", performance),
                MapUtil.entry("performanceDetail", performanceDetail)
        );

        public static long getFieldBit(String fieldName) {
            return fieldMap.getOrDefault(fieldName, 0L);
        }
    }
}
